home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / src / gdb-4.12 / gdb / value.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-03  |  15.3 KB  |  507 lines

  1. /* Definitions for values of C expressions, for GDB.
  2.    Copyright 1986, 1987, 1989, 1992 Free Software Foundation, Inc.
  3.  
  4. This file is part of GDB.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #if !defined (VALUE_H)
  21. #define VALUE_H 1
  22.  
  23. /*
  24.  * The structure which defines the type of a value.  It should never
  25.  * be possible for a program lval value to survive over a call to the inferior
  26.  * (ie to be put into the history list or an internal variable).
  27.  */
  28. enum lval_type {
  29.   /* Not an lval.  */
  30.   not_lval,
  31.   /* In memory.  Could be a saved register.  */
  32.   lval_memory,
  33.   /* In a register.  */
  34.   lval_register,
  35.   /* In a gdb internal variable.  */
  36.   lval_internalvar,
  37.   /* Part of a gdb internal variable (structure field).  */
  38.   lval_internalvar_component,
  39.   /* In a register series in a frame not the current one, which may have been
  40.      partially saved or saved in different places (otherwise would be
  41.      lval_register or lval_memory).  */
  42.   lval_reg_frame_relative
  43. };
  44.  
  45. struct value
  46.   {
  47.     /* Type of value; either not an lval, or one of the various
  48.        different possible kinds of lval.  */
  49.     enum lval_type lval;
  50.     /* Location of value (if lval).  */
  51.     union
  52.       {
  53.     /* Address in inferior or byte of registers structure.  */
  54.     CORE_ADDR address;
  55.     /* Pointer to internal variable.  */
  56.     struct internalvar *internalvar;
  57.     /* Number of register.  Only used with
  58.        lval_reg_frame_relative.  */
  59.     int regnum;
  60.       } location;
  61.     /* Describes offset of a value within lval a structure in bytes.  */
  62.     int offset;    
  63.     /* Only used for bitfields; number of bits contained in them.  */
  64.     int bitsize;
  65.     /* Only used for bitfields; position of start of field.
  66.        For BITS_BIG_ENDIAN=0 targets, it is the position of the LSB.
  67.        For BITS_BIG_ENDIAN=1 targets, it is the position of the MSB. */
  68.     int bitpos;
  69.     /* Frame value is relative to.  In practice, this address is only
  70.        used if the value is stored in several registers in other than
  71.        the current frame, and these registers have not all been saved
  72.        at the same place in memory.  This will be described in the
  73.        lval enum above as "lval_reg_frame_relative".  */
  74.     CORE_ADDR frame_addr;
  75.     /* Type of the value.  */
  76.     struct type *type;
  77.     /* Values are stored in a chain, so that they can be deleted
  78.        easily over calls to the inferior.  Values assigned to internal
  79.        variables or put into the value history are taken off this
  80.        list.  */
  81.     struct value *next;
  82.     /* If an lval is forced to repeat, a new value is created with
  83.        these fields set.  The new value is not an lval.  */
  84.     short repeated;
  85.     short repetitions;
  86.     /* Register number if the value is from a register.  Is not kept
  87.        if you take a field of a structure that is stored in a
  88.        register.  Shouldn't it be?  */
  89.     short regno;
  90.     /* If zero, contents of this value are in the contents field.
  91.        If nonzero, contents are in inferior memory at address
  92.        in the location.address field plus the offset field
  93.        (and the lval field should be lval_memory).  */
  94.     char lazy;
  95.     /* If nonzero, this is the value of a variable which does not
  96.        actually exist in the program.  */
  97.     char optimized_out;
  98.     /* Actual contents of the value.  For use of this value; setting
  99.        it uses the stuff above.  Not valid if lazy is nonzero.
  100.        Target byte-order.  We force it to be aligned properly for any
  101.        possible value.  */
  102.     union {
  103.       long contents[1];
  104.       double force_double_align;
  105. #ifdef CC_HAS_LONG_LONG
  106.       long long force_longlong_align;
  107. #endif
  108.     } aligner;
  109.  
  110.   };
  111.  
  112. typedef struct value *value;
  113.  
  114. #define VALUE_TYPE(val) (val)->type
  115. #define VALUE_LAZY(val) (val)->lazy
  116. /* VALUE_CONTENTS and VALUE_CONTENTS_RAW both return the address of
  117.    the gdb buffer used to hold a copy of the contents of the lval.  
  118.    VALUE_CONTENTS is used when the contents of the buffer are needed --
  119.    it uses value_fetch_lazy() to load the buffer from the process being 
  120.    debugged if it hasn't already been loaded.  VALUE_CONTENTS_RAW is 
  121.    used when data is being stored into the buffer, or when it is 
  122.    certain that the contents of the buffer are valid.  */
  123. #define VALUE_CONTENTS_RAW(val) ((char *) (val)->aligner.contents)
  124. #define VALUE_CONTENTS(val) ((void)(VALUE_LAZY(val) && value_fetch_lazy(val)),\
  125.                  VALUE_CONTENTS_RAW(val))
  126. extern int
  127. value_fetch_lazy PARAMS ((value val));
  128.  
  129. #define VALUE_LVAL(val) (val)->lval
  130. #define VALUE_ADDRESS(val) (val)->location.address
  131. #define VALUE_INTERNALVAR(val) (val)->location.internalvar
  132. #define VALUE_FRAME_REGNUM(val) ((val)->location.regnum)
  133. #define VALUE_FRAME(val) ((val)->frame_addr)
  134. #define VALUE_OFFSET(val) (val)->offset
  135. #define VALUE_BITSIZE(val) (val)->bitsize
  136. #define VALUE_BITPOS(val) (val)->bitpos
  137. #define VALUE_NEXT(val) (val)->next
  138. #define VALUE_REPEATED(val) (val)->repeated
  139. #define VALUE_REPETITIONS(val) (val)->repetitions
  140. #define VALUE_REGNO(val) (val)->regno
  141. #define VALUE_OPTIMIZED_OUT(val) ((val)->optimized_out)
  142.  
  143. /* Convert a REF to the object referenced. */
  144.  
  145. #define COERCE_REF(arg)    \
  146. { if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_REF)            \
  147.     arg = value_at_lazy (TYPE_TARGET_TYPE (VALUE_TYPE (arg)),        \
  148.              unpack_long (VALUE_TYPE (arg),            \
  149.                       VALUE_CONTENTS (arg)));}
  150.  
  151. /* If ARG is an array, convert it to a pointer.
  152.    If ARG is an enum, convert it to an integer.
  153.    If ARG is a function, convert it to a function pointer.
  154.  
  155.    References are dereferenced.  */
  156.  
  157. #define COERCE_ARRAY(arg)    \
  158. { COERCE_REF(arg);                            \
  159.   if (VALUE_REPEATED (arg)                        \
  160.       || TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY)        \
  161.     arg = value_coerce_array (arg);                    \
  162.   if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FUNC)                   \
  163.     arg = value_coerce_function (arg);                                  \
  164.   if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM)            \
  165.     arg = value_cast (builtin_type_unsigned_int, arg);            \
  166. }
  167.  
  168. /* If ARG is an enum, convert it to an integer.  */
  169.  
  170. #define COERCE_ENUM(arg)    \
  171. { COERCE_REF (arg); \
  172.   if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM)            \
  173.     arg = value_cast (builtin_type_unsigned_int, arg);            \
  174. }
  175.  
  176. /* Internal variables (variables for convenience of use of debugger)
  177.    are recorded as a chain of these structures.  */
  178.  
  179. struct internalvar
  180. {
  181.   struct internalvar *next;
  182.   char *name;
  183.   value value;
  184. };
  185.  
  186. /* Pointer to member function.  Depends on compiler implementation. */
  187.  
  188. #define METHOD_PTR_IS_VIRTUAL(ADDR)  ((ADDR) & 0x80000000)
  189. #define METHOD_PTR_FROM_VOFFSET(OFFSET) (0x80000000 + (OFFSET))
  190. #define METHOD_PTR_TO_VOFFSET(ADDR) (~0x80000000 & (ADDR))
  191.  
  192.  
  193. #include "symtab.h"
  194. #include "gdbtypes.h"
  195. #include "expression.h"
  196.  
  197. #ifdef __STDC__
  198. struct frame_info;
  199. struct fn_field;
  200. #endif
  201.  
  202. extern void
  203. print_address_demangle PARAMS ((CORE_ADDR, GDB_FILE *, int));
  204.  
  205. extern LONGEST
  206. value_as_long PARAMS ((value val));
  207.  
  208. extern double
  209. value_as_double PARAMS ((value val));
  210.  
  211. extern CORE_ADDR
  212. value_as_pointer PARAMS ((value val));
  213.  
  214. extern LONGEST
  215. unpack_long PARAMS ((struct type *type, char *valaddr));
  216.  
  217. extern double
  218. unpack_double PARAMS ((struct type *type, char *valaddr, int *invp));
  219.  
  220. extern CORE_ADDR unpack_pointer PARAMS ((struct type *type, char *valaddr));
  221.  
  222. extern LONGEST unpack_field_as_long PARAMS ((struct type *type, char *valaddr,
  223.                          int fieldno));
  224.  
  225. extern value value_from_longest PARAMS ((struct type *type, LONGEST num));
  226.  
  227. extern value value_from_double PARAMS ((struct type *type, double num));
  228.  
  229. extern value value_at PARAMS ((struct type *type, CORE_ADDR addr));
  230.  
  231. extern value value_at_lazy PARAMS ((struct type *type, CORE_ADDR addr));
  232.  
  233. /* FIXME:  Assumes equivalence of "struct frame_info *" and "FRAME" */
  234. extern value value_from_register PARAMS ((struct type *type, int regnum,
  235.                       struct frame_info * frame));
  236.  
  237. extern value value_of_variable PARAMS ((struct symbol *var, struct block *b));
  238.  
  239. extern value value_of_register PARAMS ((int regnum));
  240.  
  241. extern int symbol_read_needs_frame PARAMS ((struct symbol *));
  242.  
  243. /* FIXME:  Assumes equivalence of "struct frame_info *" and "FRAME" */
  244. extern value read_var_value PARAMS ((struct symbol *var,
  245.                      struct frame_info *frame));
  246.  
  247. /* FIXME:  Assumes equivalence of "struct frame_info *" and "FRAME" */
  248. extern value locate_var_value PARAMS ((struct symbol *var,
  249.                        struct frame_info *frame));
  250.  
  251. extern value allocate_value PARAMS ((struct type *type));
  252.  
  253. extern value allocate_repeat_value PARAMS ((struct type *type, int count));
  254.  
  255. extern value value_mark PARAMS ((void));
  256.  
  257. extern void value_free_to_mark PARAMS ((value mark));
  258.  
  259. extern value value_string PARAMS ((char *ptr, int len));
  260.  
  261. extern value value_array PARAMS ((int lowbound, int highbound,
  262.                   value *elemvec));
  263.  
  264. extern value value_concat PARAMS ((value arg1, value arg2));
  265.  
  266. extern value value_binop PARAMS ((value arg1, value arg2, enum exp_opcode op));
  267.  
  268. extern value value_add PARAMS ((value arg1, value arg2));
  269.  
  270. extern value value_sub PARAMS ((value arg1, value arg2));
  271.  
  272. extern value value_coerce_array PARAMS ((value arg1));
  273.  
  274. extern value value_coerce_function PARAMS ((value arg1));
  275.  
  276. extern value value_ind PARAMS ((value arg1));
  277.  
  278. extern value value_addr PARAMS ((value arg1));
  279.  
  280. extern value value_assign PARAMS ((value toval, value fromval));
  281.  
  282. extern value value_neg PARAMS ((value arg1));
  283.  
  284. extern value value_complement PARAMS ((value arg1));
  285.  
  286. extern value value_struct_elt PARAMS ((value *argp, value *args, char *name,
  287.                        int *static_memfuncp, char *err));
  288.  
  289. extern value value_struct_elt_for_reference PARAMS ((struct type *domain,
  290.                              int offset,
  291.                              struct type *curtype,
  292.                              char *name,
  293.                              struct type *intype));
  294.  
  295. extern value value_field PARAMS ((value arg1, int fieldno));
  296.  
  297. extern value value_primitive_field PARAMS ((value arg1, int offset,
  298.                         int fieldno,
  299.                         struct type *arg_type));
  300.  
  301. extern value value_cast PARAMS ((struct type *type, value arg2));
  302.  
  303. extern value value_zero PARAMS ((struct type *type, enum lval_type lv));
  304.  
  305. extern value value_repeat PARAMS ((value arg1, int count));
  306.  
  307. extern value value_subscript PARAMS ((value array, value idx));
  308.  
  309. extern value value_from_vtable_info PARAMS ((value arg, struct type *type));
  310.  
  311. extern value value_being_returned PARAMS ((struct type *valtype, 
  312.                        char retbuf[REGISTER_BYTES],
  313.                        int struct_return));
  314.  
  315. extern value value_in PARAMS ((value element, value set));
  316.  
  317. extern int value_bit_index PARAMS ((struct type *type, char *addr, int index));
  318.  
  319. extern int
  320. using_struct_return PARAMS ((value function, CORE_ADDR funcaddr,
  321.                  struct type *value_type, int gcc_p));
  322.  
  323. extern void
  324. set_return_value PARAMS ((value val));
  325.  
  326. extern value
  327. evaluate_expression PARAMS ((struct expression *exp));
  328.  
  329. extern value
  330. evaluate_type PARAMS ((struct expression *exp));
  331.  
  332. extern value
  333. parse_and_eval PARAMS ((char *exp));
  334.  
  335. extern value
  336. parse_to_comma_and_eval PARAMS ((char **expp));
  337.  
  338. extern struct type *
  339. parse_and_eval_type PARAMS ((char *p, int length));
  340.  
  341. extern CORE_ADDR
  342. parse_and_eval_address PARAMS ((char *exp));
  343.  
  344. extern CORE_ADDR
  345. parse_and_eval_address_1 PARAMS ((char **expptr));
  346.  
  347. extern value
  348. access_value_history PARAMS ((int num));
  349.  
  350. extern value
  351. value_of_internalvar PARAMS ((struct internalvar *var));
  352.  
  353. extern void
  354. set_internalvar PARAMS ((struct internalvar *var, value val));
  355.  
  356. extern void
  357. set_internalvar_component PARAMS ((struct internalvar *var, int offset,
  358.                    int bitpos, int bitsize,
  359.                    value newvalue));
  360.  
  361. extern struct internalvar *
  362. lookup_internalvar PARAMS ((char *name));
  363.  
  364. extern int
  365. value_equal PARAMS ((value arg1, value arg2));
  366.  
  367. extern int
  368. value_less PARAMS ((value arg1, value arg2));
  369.  
  370. extern int
  371. value_logical_not PARAMS ((value arg1));
  372.  
  373. /* C++ */
  374.  
  375. extern value
  376. value_of_this PARAMS ((int complain));
  377.  
  378. extern value
  379. value_x_binop PARAMS ((value arg1, value arg2, enum exp_opcode op,
  380.                enum exp_opcode otherop));
  381.  
  382. extern value
  383. value_x_unop PARAMS ((value arg1, enum exp_opcode op));
  384.  
  385. extern value
  386. value_fn_field PARAMS ((value *arg1p, struct fn_field *f, int j,
  387.             struct type* type, int offset));
  388.  
  389. extern value
  390. value_virtual_fn_field PARAMS ((value *arg1p, struct fn_field *f, int j,
  391.                 struct type *type, int offset));
  392.  
  393. extern int
  394. binop_user_defined_p PARAMS ((enum exp_opcode op, value arg1, value arg2));
  395.  
  396. extern int
  397. unop_user_defined_p PARAMS ((enum exp_opcode op, value arg1));
  398.  
  399. extern int
  400. destructor_name_p PARAMS ((const char *name, const struct type *type));
  401.  
  402. #define value_free(val) free ((PTR)val)
  403.  
  404. extern void
  405. free_all_values PARAMS ((void));
  406.  
  407. extern void
  408. release_value PARAMS ((value val));
  409.  
  410. extern int
  411. record_latest_value PARAMS ((value val));
  412.  
  413. extern void
  414. registers_changed PARAMS ((void));
  415.  
  416. extern void
  417. read_register_bytes PARAMS ((int regbyte, char *myaddr, int len));
  418.  
  419. extern void
  420. write_register_bytes PARAMS ((int regbyte, char *myaddr, int len));
  421.  
  422. extern void
  423. read_register_gen PARAMS ((int regno, char *myaddr));
  424.  
  425. extern CORE_ADDR
  426. read_register PARAMS ((int regno));
  427.  
  428. extern void
  429. write_register PARAMS ((int regno, LONGEST val));
  430.  
  431. extern void
  432. supply_register PARAMS ((int regno, char *val));
  433.  
  434. /* FIXME:  Assumes equivalence of "struct frame_info *" and "FRAME" */
  435. extern void
  436. get_saved_register PARAMS ((char *raw_buffer, int *optimized,
  437.                 CORE_ADDR *addrp, struct frame_info *frame,
  438.                 int regnum, enum lval_type *lval));
  439.  
  440. extern void
  441. modify_field PARAMS ((char *addr, LONGEST fieldval, int bitpos, int bitsize));
  442.  
  443. extern void
  444. type_print PARAMS ((struct type *type, char *varstring, GDB_FILE *stream,
  445.             int show));
  446.  
  447. extern char *
  448. baseclass_addr PARAMS ((struct type *type, int index, char *valaddr,
  449.             value *valuep, int *errp));
  450.  
  451. extern void
  452. print_longest PARAMS ((GDB_FILE *stream, int format, int use_local,
  453.                LONGEST value));
  454.  
  455. extern void
  456. print_floating PARAMS ((char *valaddr, struct type *type, GDB_FILE *stream));
  457.  
  458. extern int
  459. value_print PARAMS ((value val, GDB_FILE *stream, int format,
  460.              enum val_prettyprint pretty));
  461.  
  462. extern int
  463. val_print PARAMS ((struct type *type, char *valaddr, CORE_ADDR address,
  464.            GDB_FILE *stream, int format, int deref_ref,
  465.            int recurse, enum val_prettyprint pretty));
  466.  
  467. extern int
  468. val_print_string PARAMS ((CORE_ADDR addr, unsigned int len, GDB_FILE *stream));
  469.  
  470. /* FIXME:  Assumes equivalence of "struct frame_info *" and "FRAME" */
  471. extern void
  472. print_variable_value PARAMS ((struct symbol *var, struct frame_info *frame,
  473.                   GDB_FILE *stream));
  474.  
  475. extern value
  476. value_arg_coerce PARAMS ((value));
  477.  
  478. extern int
  479. check_field PARAMS ((value, const char *));
  480.  
  481. extern void
  482. c_typedef_print PARAMS ((struct type *type, struct symbol *new, GDB_FILE *stream));
  483.  
  484. extern char *
  485. internalvar_name PARAMS ((struct internalvar *var));
  486.  
  487. extern void
  488. clear_value_history PARAMS ((void));
  489.  
  490. extern void
  491. clear_internalvars PARAMS ((void));
  492.  
  493. /* From values.c */
  494.  
  495. extern value
  496. value_copy PARAMS ((value));
  497.  
  498. extern int
  499. baseclass_offset PARAMS ((struct type *, int, value, int));
  500.  
  501. /* From valops.c */
  502.  
  503. extern value
  504. call_function_by_hand PARAMS ((value, int, value *));
  505.  
  506. #endif    /* !defined (VALUE_H) */
  507.